var React = require('react');

var Icon = require('../components/Icon');

module.exports = React.createClass({
    getInitialState: function () {
        return {
            theme:"Default",
            addressList:[],
        }
    },

    componentDidMount: function () {

    },

    action(e){
        var action = e.currentTarget.getAttribute("action");
        location.href = action;
    },

    render: function () {
        var p = this;
        var addressList = this.state.addressList.map(function (obj) {
            var idnumber = obj.idnumber.replace(obj.idnumber.substr(10,6), "******");
            return (
                <div key={obj.id} className="addressInfo">
                    <div className="isdefault" style={{display:obj.isdefault == 1 ? "block" : "none"}}>
                        <Icon icon="#icon-xuanzhong1" style={{fontSize:"1.05rem",color:"#FF0000"}}/>
                    </div>
                    <div className="addressList">
                        <div className="user-info">
                            <p style={{color: obj.isdefault == 1 ? "#FF0000" : "#333"}}>
                                <span className="realname">{obj.realname}</span>
                                <span className="phone">{obj.mobile}</span>
                            </p>
                            <p>
                                <span className="zipcode">{obj.zipcode}</span>
                                <span className="idnumber">{idnumber}</span>
                            </p>
                        </div>
                        <div className="address">
                            {obj.province+obj.city+obj.district+obj.area+obj.address}
                        </div>
                        <div className="addressBtn" onClick={p.action} action={"#editAddress/" + obj.id}>
                            <Icon icon="#icon-bianji" style={{fontSize:"1.05rem"}}/>
                        </div>
                    </div>
                </div>
            )
        });
        return(
            <div>
                {addressList}
            </div>
        )
    }
});

